package com.example.moduletwo.binder;

import android.text.TextUtils;

import com.example.moduletwo.bean.TwoMVPBean;
import com.example.moduletwo.delegate.ModuleTwoMVPActivityDelegate;
import com.example.mvp.binder.BaseDataBinder;

/**
 * 数据视图绑定（数据驱动视图无延迟刷新）
 * Created by sun.li on 2018/6/5.
 *
 * @author sun.li
 */

public class TwoMVPFragmentBinder implements BaseDataBinder<ModuleTwoMVPActivityDelegate, TwoMVPBean> {

    @Override
    public void viewBindModel(ModuleTwoMVPActivityDelegate viewDelegate, TwoMVPBean data) {
        if (null == data || null == viewDelegate) {
            return;
        }
        str1BindView(viewDelegate, data.getStr1());

        if (!TextUtils.isEmpty(data.getStr2())) {
            viewDelegate.setText2(data.getStr2());
        }

        new TwoMVPBinderOne().viewBindModel(viewDelegate, data.getTwoMVPBeanOne());
    }

    @Override
    public Class<TwoMVPBean> getDataClass() {
        return TwoMVPBean.class;
    }

    /**
     * 数据对象1业务处理
     */
    private void str1BindView(final ModuleTwoMVPActivityDelegate viewDelegate, final String str1) {
        if (!TextUtils.isEmpty(str1)) {
            viewDelegate.setText1(str1);
        }
    }


}
